package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.pojo.DtsCategory;
import com.qf.pojo.DtsOrder;
import com.qf.pojo.DtsOrderGoods;
import com.qf.pojo.DtsUser;
import com.qf.service.DtsOrderService;
import com.qf.service.DtsUserService;
import com.qf.util.ResponseUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/admin/order")
@CrossOrigin
@Slf4j
public class OrderController{
    @Autowired
    private DtsOrderService dtsOrderService;
    @Autowired
    private DtsUserService dtsUserService;
    @RequestMapping("/list")
    public Object findOrder(int page,int limit,String sort,String order,Integer userId,String orderSn,int[] orderStatusArray){
        IPage<DtsOrder> dtsOrders = dtsOrderService.selectPage(page, limit, sort, order,userId,orderSn, orderStatusArray);

        Map<String,Object> result =new HashMap<>();

        result.put("total",dtsOrders.getTotal());
        result.put("items",dtsOrders.getRecords());
        return ResponseUtil.ok(result);
    }
    //快递公司列表
    //http://localhost:8083/admin/order/listShipChannel
    @RequestMapping("/listShipChannel")
    public Object listShipChannel(){
        return ResponseUtil.ok();
    }
    //订单详情
    //接口地址 : http://localhost:8083/admin/order/detail?id=98
    @RequestMapping("/detail")
    public Object listShipChannel(int id){
        DtsOrderGoods orderGoods=dtsOrderService.findorderGoods(id);
        DtsUser user=dtsUserService.finduser(id);
        DtsOrder order=dtsOrderService.findorder(id);
        Map<String,Object> result =new HashMap<>();

        result.put("orderGoods",orderGoods);
        result.put("user",user);
        result.put("order",order);
        return ResponseUtil.ok(result);
    }



}
